package com.zjh;

import com.zjh.bean.Student;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.Reader;

/**
 * @author LiZiQiu
 * @data 2023/3/1
 */
public class Test2_2 {

    public static void main(String[] args) {
        try {
            Reader reader = Resources.getResourceAsReader("mybatis-config.xml");
            SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
            SqlSessionFactory build = builder.build(reader, "a2");
            SqlSession session = build.openSession();
            Student o = session.selectOne("com.zjh.dao.StudentDao.findById",3);
            System.out.println(o.getName());

            System.out.println("-------------------------");
            SqlSession session2 = build.openSession();
            Student o1 = session.selectOne("com.zjh.dao.StudentDao.findById",3);
            System.out.println(o1.getName());
        } catch (IOException e) {
            e.printStackTrace();
        }


    }


}
